package com.miya.demo.common.converter;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * 客户转换器
 *
 * @author Caixiaowei
 * @date 2022/01/18
 */
public class CustomerConverter implements Converter<String> {


	@Override
	public Class supportJavaTypeKey() {
		return String.class;
	}

	@Override
	public CellDataTypeEnum supportExcelTypeKey() {
		return CellDataTypeEnum.STRING;
	}

	/**
	 * 转换为java数据: 导入==>将导入Excel内容转为java 类型的数据
	 *
	 * @param cellData             单元格数据
	 * @param excelContentProperty excel内容属性
	 * @param globalConfiguration  全局配置
	 * @return {@link String}
	 * @throws Exception 异常
	 */
	@Override
	public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
		return null;
	}

	/**
	 * 转换为excel数据: 导出==>将java数据转为Excel显示的内容
	 *
	 * @param value                    年代
	 * @param excelContentProperty excel内容属性
	 * @param globalConfiguration  全局配置
	 * @return {@link CellData}
	 * @throws Exception 异常
	 */
	@Override
	public CellData convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
		return new CellData(StrUtil.join(StrUtil.UNDERLINE, "测试", value));
	}
}
